package com.core.thread;

public class Ticket implements Runnable {

    int tickt = 100;

    @Override
    public void run() {
        while (tickt > 0) {

            synchronized (this) {
                if (tickt > 0) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + "售出第" + (100 - tickt + 1) + "张票");
                    tickt--;
                }
            }

        }

    }

}
